<script setup>
import { computed, inject, useSlots } from 'vue'

const props = defineProps({
    /**
     * 将列固定在左侧或者右侧
     */
    fixed: {
        type: String,
        validator: (value) => ['left', 'right'].includes(value)
    },
    /**
     * 列字段名
     */
    field: String
})

const slots = useSlots()

const currentTable = inject('currentTable', null)

const fixed = computed(() => {
    //一旦进入拖拽模式，就不允许固定列，因为样式 会乱
    return currentTable?.props.dragable ? null : props.fixed
})
</script>

<template>
    <vxe-column :fixed="fixed" :field="field">
        <template v-for="(_item, key) in slots" :key="key" #[key]="data">
            <slot :name="key" v-bind="data ?? {}" />
        </template>
    </vxe-column>
</template>

<style scoped></style>
